package com.umeox.moto.watch.themes.skin.entity;

import static com.umeox.moto.watch.themes.skin.entity.AttrFactory.SEEK_BAR_PROGRESS_DRAWABLE;
import static com.umeox.moto.watch.themes.skin.entity.AttrFactory.THUMB;

import android.graphics.drawable.Drawable;
import android.view.View;
import android.widget.SeekBar;

import com.umeox.moto.watch.themes.skin.loader.ResourceManager;
import com.umeox.moto.watch.themes.widget.VerticalSeekBar;

/**
 * Created by Rambo 2024/8/26/Monday
 * Describe:
 */

public class SeekBarAttr extends SkinAttr {

    @Override
    public void apply(View view) {
        if (view instanceof VerticalSeekBar) {
            VerticalSeekBar seekBar = (VerticalSeekBar) view;
            if (RES_TYPE_NAME_DRAWABLE.equals(attrValueTypeName)) {
                if (SEEK_BAR_PROGRESS_DRAWABLE.equals(attrName)) {
                    Drawable bg = ResourceManager.getInstance().getDrawable(attrValueRefId);
                    seekBar.setProgressDrawable(bg);
                } else if (THUMB.equals(attrName)) {
                    seekBar.setThumb(ResourceManager.getInstance().getDrawable(attrValueRefId));
                    seekBar.setThumbOffset(0);
                }
            }
        } else if (view instanceof SeekBar) {
            SeekBar seekBar = (SeekBar) view;
            if (RES_TYPE_NAME_DRAWABLE.equals(attrValueTypeName)) {
                if (SEEK_BAR_PROGRESS_DRAWABLE.equals(attrName)) {
                    Drawable bg = ResourceManager.getInstance().getDrawable(attrValueRefId);
                    seekBar.setProgressDrawable(bg);
                } else if (THUMB.equals(attrName)) {
                    seekBar.setThumb(ResourceManager.getInstance().getDrawable(attrValueRefId));
                    seekBar.setThumbOffset(0);
                }
            }
        }
    }
}

